<ion-view view-title="运单详情" cache-view="false" ng-init="init()" hide-back-button="false">
  <ion-nav-buttons side="right">
    <button class="button chat_btn" ng-click="tochat()" ng-hide="hidechat"></button>
  </ion-nav-buttons>
  <ion-content class="gray_back">
    <section class="g_main">
      <!-- 运单发车详情 -->
      <ul class="tab_back" ng-if="!onlyLine && waybillInfo.waybill_state >= 2 && userInfo.member_type !== 2">
        <li ng-class="tab_class[0]" ng-click="toggleShowflag()">运单详情</li>
        <li ng-class="tab_class[1]" ng-click="toggleShowflag()">运单查询</li>
        <i ng-class="scrollclass"></i>
      </ul>
      <section class="truck_line track_line-edit submit_info" ng-hide="showflag">
        <div class="info_list">
          <ul>
            <li>
              <h4>发货人</h4>
              <p>{{waybillInfo.cargo_owner}}</p>
            </li>
            <li>
              <h4>承运人</h4>
              <p>{{waybillInfo.carrier_owner}}</p>
            </li>
          </ul>
          <ul>
            <li>
              <h4>装货日期</h4>
              <p>{{waybillInfo.shipment_time_disp}}</p>
            </li>
            <li>
              <h4>起点</h4>
              <p>{{waybillInfo.start_area_disp}}</p>
            </li>
            <li>
              <h4>详细地址</h4>
              <p>{{waybillInfo.start_addr}}</p>
            </li>
            <li>
              <h4>终点</h4>
              <p>{{waybillInfo.end_area_disp}}</p>
            </li>
            <li>
              <h4>详细地址</h4>
              <p>{{waybillInfo.end_addr}}</p>
            </li>
          </ul>
          <ul>
            <li>
              <h4>货物名称</h4>
              <p>{{waybillInfo.cargo_name}}</p>
            </li>
            <li>
              <h4>体积</h4>
              <p>{{waybillInfo.cargo_bulk}}立方</p>
            </li>
            <li>
              <h4>重量</h4>
              <p>{{waybillInfo.cargo_weight}}吨</p>
            </li>
            <li ng-if="waybillInfo.waybill_state >= 3">
              <h4>次数</h4>
              <p>{{waybillInfo.cargo_count}}</p>
            </li>
          </ul>
          <ul>
            <li>
              <h4 ng-show="waybillInfo.line_type==1">车牌</h4>
              <h4 ng-show="waybillInfo.line_type==2">船舶识别号</h4>
              <p>{{waybillInfo.vehicle_no}}</p>
            </li>
            <li>
              <h4 ng-show="waybillInfo.line_type==1">车型</h4>
              <h4 ng-show="waybillInfo.line_type==2">船舶类型</h4>
              <p>{{waybillInfo.vehicle_type_disp}}</p>
            </li>
            <li>
              <h4 ng-show="waybillInfo.line_type==1">车长</h4>
              <h4 ng-show="waybillInfo.line_type==2">船长</h4>
              <p>{{vehiclelens[waybillInfo.vehicle_len]}}</p>
            </li>
            <li>
              <h4>吨位</h4>
              <p>{{waybillInfo.vehicle_load}}吨</p>
            </li>
          </ul>
          <ul>
            <li style="height:50px">
              <h4>保证金</h4>
              <p ng-if="waybillInfo.waybill_state > 0">{{waybillInfo.deposit}}元（已支付到平台）</p>
              <p ng-if="waybillInfo.waybill_state === 0">{{waybillInfo.deposit}}元</p>
            </li>
            <li style="height:50px">
              <h4 ng-show="waybillInfo.waybill_state < 4" style="line-height: 20px; height:50px">初&nbsp;定&nbsp;运&nbsp;价<BR>（除保证金）</h4>
              <h4 ng-hide="waybillInfo.waybill_state < 4" style="line-height: 20px; height:50px">运价<BR>（除保证金）</h4>
              <p>{{waybillInfo.price}}元</p>
            </li>
            <li ng-if="waybillInfo.cargo_value">
              <h4>货品价值</h4>
              <p>{{waybillInfo.cargo_value}}元</p>
            </li>
          </ul>
          <ul>
            <li>
              <h4>装货联系人</h4>
              <p>{{waybillInfo.consignor}}</p>
            </li>
            <li>
              <h4>联系人电话</h4>
              <a ng-href="tel:{{waybillInfo.consignor_phone}}"><p>{{waybillInfo.consignor_phone}}</p></a>
            </li>
            <li>
              <h4>备注</h4>
              <p>{{waybillInfo.remark}}</p>
            </li>
            <li ng-show="[3,4,5,6,7,8].indexOf(waybillInfo.waybill_state) > -1">
              <h4>支付方式</h4>
              <p>{{waybillInfo.payment_term==1?'线下支付':'线上支付'}}</p>
            </li>
          </ul>
          <ul ng-show="waybillInfo.payment_term === 1">
            <li  >
              <h4>指定收款人</h4>
              <p>{{offlinePayInfo.payee}}&nbsp;</p>
            </li>
            <li  >
              <h4>身份证号</h4>
              <p>{{offlinePayInfo.payee_idcard}}&nbsp;</p>
            </li>
            <li  >
              <h4>开户行</h4>
              <p>{{offlinePayInfo.bank_name}}&nbsp;</p>
            </li>
            <li  >
              <h4>银行卡号</h4>
              <p>{{offlinePayInfo.bank_card}}&nbsp;</p>
            </li>
          </ul>
          <ul ng-show="waybillInfo.invoice_info && waybillInfo.invoice_info.title && (userInfo.member_type === 1 || userInfo.member_type === 3)">
            <li class="select" ng-click="toAddressEdit()">
              <h4>发票信息</h4>
              <p style="text-align: right; font-weight: bold">>></p>
            </li>
          </ul>
          <ul ng-show="waybillInfo.waybill_state>=4 && (userInfo.member_type==2 || userInfo.member_type==4) && waybillInfo.payment_term !== 1">
            <li class="radio" style="padding:0px">
              <ion-toggle ng-model="waybillInfo.need_oil_card" toggle-class="toggle-calm"
               ng-change="need_oilcard_change()" ng-disabled="waybillInfo.waybill_state>4">是否需要油卡</ion-toggle>
            </li>
          </ul>
          <ul ng-show="waybillInfo.need_oil_card && waybillInfo.waybill_state==4 && (userInfo.member_type==2 || userInfo.member_type==4)  && waybillInfo.payment_term !== 1">
            <li>
              <h4>油卡号</h4>
               <input type="text" placeholder="请输入油卡号" ng-model="waybillInfo.oil_card_no" style="height:26px;">
          </li>
          </ul>
          <ul ng-show="waybillInfo.need_oil_card && waybillInfo.waybill_state>4 && (userInfo.member_type==2 || userInfo.member_type==4)  && waybillInfo.payment_term !== 1">
            <li>
              <h4>油卡号</h4>
              <p style="height:26px;">{{waybillInfo.oil_card_no}}</p>
            </li>
          </ul>
          <ul ng-show="[3,4,5,6,7].indexOf(waybillInfo.waybill_state) > -1">
            <li class="arrow" ng-click="toProtocol(2)">
              <h4>查看协议</h4>
              <p style="text-align: right; font-weight: bold">>></p>
            </li>
          </ul>
        </div>
        <!--waybillInfo.waybill_state==0-->
        <button ng-click="changeWaybillState(10)" class="btn_save" ng-if="waybillInfo.waybill_state==0 && (userInfo.member_type==2 || userInfo.member_type==4)">取消运单</button>
        <div class="btn_box" ng-if="waybillInfo.waybill_state==0 && userInfo.member_type!=2 && userInfo.member_type!=4">
          <button ng-click="pay()" class="btn_save">重新支付</button>
          <button ng-click="changeWaybillState(10)" class="btn_cancel">取消运单</button>
        </div>
        <!--waybillInfo.waybill_state==1-->
        <div class="btn_box" ng-if="waybillInfo.waybill_state==1 && (userInfo.member_type==2 || userInfo.member_type==4)">
          <button ng-click="changeWaybillState(2)" class="btn_save">接单</button>
          <button ng-click="changeWaybillState(10)" class="btn_cancel">拒绝</button>
        </div>
        <button ng-click="changeWaybillState(10)" class="btn_save" ng-if="waybillInfo.waybill_state==1 && userInfo.member_type!=2 && userInfo.member_type!=4">取消运单</button>
        <!--waybillInfo.waybill_state==2-->
        <button ng-click="changeWaybillState(10)" class="btn_save" ng-if="waybillInfo.waybill_state==2 && userInfo.member_type==2 && userInfo.member_type!=4">取消运单</button>
        <div class="btn_box" ng-if="waybillInfo.waybill_state==2 && userInfo.member_type!=2 && userInfo.member_type!=4">
          <button ng-click="toProtocol(0)" class="btn_save">发起协议</button>
          <button ng-click="changeWaybillState(10)" class="btn_cancel">取消运单</button>
        </div>
        <!--waybillInfo.waybill_state==3-->
        <button ng-click="changeWaybillState(10)" class="btn_save" ng-if="waybillInfo.waybill_state==3 && userInfo.member_type==2 && userInfo.member_type!=4">取消运单</button>
        <div class="btn_box" ng-if="waybillInfo.waybill_state==3 && userInfo.member_type!=2 && userInfo.member_type!=4">
          <button ng-click="pay()" class="btn_save">重新支付</button>
          <button ng-click="changeWaybillState(10)" class="btn_cancel">取消运单</button>
        </div>
        <!--waybillInfo.waybill_state==4-->
        <div class="btn_box" ng-if="waybillInfo.waybill_state==4 && (userInfo.member_type==2 || userInfo.member_type==4)">
          <button ng-click="toProtocol(1)" class=" btn_save ">签署协议</button>
          <button ng-click="changeWaybillState(10)" class=" btn_cancel ">取消运单</button>
        </div>

        <button ng-click="changeWaybillState(10)" class="btn_save" ng-if="waybillInfo.waybill_state==4 && userInfo.member_type!=2 && userInfo.member_type!=4">取消运单</button>
        <!--waybillInfo.waybill_state==5-->
        <button ng-click="confirmWaybill()" class="btn_save" ng-if="waybillInfo.waybill_state==5 && (userInfo.member_type==2 || userInfo.member_type==4)">我已到达</button>
        <button class="btn_save" ng-click="confirmWaybill()" ng-show="((userInfo.member_type==1 || userInfo.member_type==3) && (waybillInfo.waybill_state == 6 || waybillInfo.waybill_state == 5))">确认收货</button>
        <div class="btn_box" ng-show="waybillInfo.waybill_state>=4 && (userInfo.member_type==2 || userInfo.member_type==4)">
         1、签署协议（不要油卡）：<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;运费全额现金发放到个人钱包<br/>
         2、签署协议（需要油卡）：<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;运费60%现金发放到个人钱包+40%油卡充值
        </div>
        <button ng-click="toRate()" class="btn_save" ng-if="waybillInfo.waybill_state==7 && userInfo.member_type==1">评价</button>
      </section>
      <div ng-show="showflag">
        <div id="mapcontent" style="height:{{mapHeight}}px"></div>
      </div>
    </section>
  </ion-content>
</ion-view>
